#!/bin/gprolog --consult-file

:- include('data.pl').

% Your code goes here.

startmatch(time(Qstarthour,Qstartminute),time(Shour,Sminute)) :-
	Qstarthour==Shour, Qstartminute>=Sminute.
startmatch(time(Qstarthour,_),time(Shour,_)) :-
	Qstarthour>Shour.

% <= : less or equal to.
endmatch(time(Qendhour,Qendminute),time(Ehour,Eminute)) :-
	Qendhour==Ehour, Qendminute=<Eminute.
endmatch(time(Qendhour,_),time(Ehour,_)) :-
	Qendhour<Ehour.
	
available(slot(Querystarttime,Queryendtime), slot(Starttime,Endtime)) :- 
	startmatch(Querystarttime,Starttime), endmatch(Queryendtime,Endtime). 

meetone(Person,SlotQuery) :- 
	free(Person,Slot), available(SlotQuery, Slot).

main :- findall(Person, meetone(Person,slot(time(8,30),time(8,45))), People),
	write(People), nl, halt.

:- initialization(main).
